package com.jxb.basic;

import java.io.UnsupportedEncodingException;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingException;

/**
 * 类注释
 *
 * @author jiaobo
 * @date Created in 2024/9/10 20:55
 **/
public class SyncProduct {

    public static void main(String[] args)
            throws MQClientException, UnsupportedEncodingException, RemotingException, InterruptedException,
            MQBrokerException {
        DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
        producer.setNamesrvAddr("192.168.3.41:9876");
        producer.start();

        for (int i = 0; i < 1; i++) {
            Message message = new Message("other_send_warn",
                                          "{\"sendWarnMessages\":[{\"uniqueCode\":\"a09d8f70c4a240e0a0aa08f912024-12-05-08234305747699\",\"alarmTitle\":\"电动车驶入\",\"alarmInfo\":\"\",\"algorithmName\":\"电动车识别\",\"algorithmCode\":\"B0012023Q0010101HW2\",\"analyseType\":null,\"alarmTime\":1733358222912,\"alarmImage\":\"http://192.168.3.41:18079/admin-api/infra/file/5/get/c5a5de331681b233d8d185a331e2dbb2953dd6377163d669fef3bfd47cb57688.jpg\",\"cameraIp\":\"192.168.2.31\",\"regionName\":\"安徽天辰化工股份有限公司\",\"regionCode\":\"020230711103245513\",\"serialNumber\":null}]}".getBytes(RemotingHelper.DEFAULT_CHARSET));
            // producer.sendOneway(message);
            SendResult send = producer.send(message);
            System.out.println("发送状态："+send.getSendStatus());
        }

        producer.shutdown();

    }

}
